package com.zyg.manager.service.impl;

import com.zyg.manager.dao.ItemDao;
import com.zyg.manager.entity.ItemEntity;
import com.zyg.manager.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyg.common.utils.PageUtils;
import com.zyg.common.utils.Query;

import com.zyg.manager.dao.GoodsDao;
import com.zyg.manager.entity.GoodsEntity;
import com.zyg.manager.service.GoodsService;


@Service("goodsService")
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, GoodsEntity> implements GoodsService {




    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<GoodsEntity> page = this.page(
                new Query<GoodsEntity>().getPage(params),
                new QueryWrapper<GoodsEntity>()
        );
        return new PageUtils(page);
    }
    /**
     * 作者：LMY
     * 功能：商品审核
     * 时间：2021/10/26 19:57
     */
    @Override
    public void updateStatus(Long id, String auditStatus) {
        //第一部分：修改goods商品的状态
        //1. 根据id查询出商品对象
        GoodsEntity goodsEntity = baseMapper.selectById(id);
        //2. 覆盖原来的状态码
        goodsEntity.setAuditStatus(auditStatus);
        //3. 执行修改
        baseMapper.updateById(goodsEntity);


    }

    @Override
    public PageUtils queryPage2(Map<String, Object> params) {
        IPage<GoodsEntity> page = this.page(
                new Query<GoodsEntity>().getPage(params),
                new QueryWrapper<GoodsEntity>().eq("audit_status","0")
        );
        return new PageUtils(page);
    }
}